package com.huabo.audit.oracle.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huabo.audit.oracle.entity.TblNbsjProjectDataEntity;
import com.huabo.audit.oracle.vo.DataProVo;
import com.huabo.audit.util.PageInfo;

public interface TblNbsjProjectDataMapper extends BaseMapper<TblNbsjProjectDataEntity>{
	@Delete("DELETE from TBL_PROJECT_DATAPRE WHERE ID= #{dataId} ")
    void delete(String dataId);
	
	@Select("SELECT * from TBL_PROJECT_DATAPRE WHERE PROJECTID= #{projectId} ")
    List<TblNbsjProjectDataEntity> findAll(String projectId);
	
	@Select("SELECT * from TBL_PROJECT_DATAPRE WHERE NOTEID = #{noteid} ")
    TblNbsjProjectDataEntity get(String noteid);
	
	@Select("SELECT * from TBL_PROJECT_DATAPRE WHERE PROJECTID= #{projectId} ")
    List<TblNbsjProjectDataEntity> isNoteCode(String code,String projectId);
	
	
	
	//==
	@Select("SELECT * from TBL_PROJECT_DATAPRE WHERE ID= #{dataId} ")
    TblNbsjProjectDataEntity getById(String dataId);
    
    @SelectProvider(method="selectCountByPageInfo",type=TblNbsjProjectDataMapperSqlConfig.class)
   	Integer selectCountByPageInfo(PageInfo<TblNbsjProjectDataEntity> pageInfo,DataProVo dataProVo,Integer orgid,Integer projectId) throws Exception;

    @Select("SELECT TNA.* FROM TBL_PROJECT_DATAPRE TNA  WHERE TNA.ID = #{dataId}")
    @Results({
    	@Result(column="ID",property="dataId"),
    	@Result(column="PROJECTID",property="projectId"),
    	@Result(column="DATA_NAME",property="dataName"),
    	@Result(column="DATA_CAPACITY",property="dataCapacity"),
    	@Result(column="DATA_DATE",property="dataDate"),
    	
    	@Result(column="PROJECTNAME",property="projectname"),
    	@Result(column="USERNAME",property="username"),
    	
    	@Result(column="PROJECT_DATAPRE_ID",property="projectDataPreId"),
    	
    })
   	TblNbsjProjectDataEntity selectById(@Param("dataId") Integer dataId) throws Exception;
    
    @SelectProvider(method="selectListByPageInfo",type=TblNbsjProjectDataMapperSqlConfig.class)
    @Results({
    	@Result(column="ID",property="dataId"),
    	@Result(column="PROJECTID",property="projectId"),
    	@Result(column="DATA_NAME",property="dataName"),
    	@Result(column="DATA_CAPACITY",property="dataCapacity"),
    	@Result(column="DATA_DATE",property="dataDate"),
    	@Result(column="PROJECTNAME",property="projectname"),
    	@Result(column="USERNAME",property="username"),
    	@Result(column="PROJECT_DATAPRE_ID",property="projectDataPreId"),
    })
	List<TblNbsjProjectDataEntity> selectListByPageInfo(PageInfo<TblNbsjProjectDataEntity> pageInfo,DataProVo dataProVo,Integer orgid,Integer projectId) throws Exception;

    @Delete("DELETE FROM TBL_PROJECT_DATAPRE WHERE ID = #{dataId}")
    void deleteById(Integer dataId) throws Exception;

    @SelectProvider(method="selectPlanCodeByOrgid",type=TblNbsjProjectDataMapperSqlConfig.class)
	Integer selectPlanCodeByOrgid(TblNbsjProjectDataEntity plan) throws Exception;
    
    @InsertProvider(method="insertEntity",type=TblNbsjProjectDataMapperSqlConfig.class)
    @Options(useGeneratedKeys=true, keyProperty="dataId", keyColumn="ID")
	void insertEntity(TblNbsjProjectDataEntity plan) throws Exception;

    @UpdateProvider(method="updateEntity",type=TblNbsjProjectDataMapperSqlConfig.class)
	void updateEntity(TblNbsjProjectDataEntity plan) throws Exception;
    
    
    @InsertProvider(method="saveOld",type=TblNbsjProjectDataMapperSqlConfig.class)
    @Options(useGeneratedKeys=true, keyProperty="dataId", keyColumn="DATAID")
	void saveOld(TblNbsjProjectDataEntity data) throws Exception;
    
    @Delete("DELETE FROM TBL_LEGAL_DATAPROJECT_ATT WHERE attid=#{attid}")
	void deleteFileInfoByAttId(Integer attid);
}
